package Util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import Form.ActionForm;
/*
 * 用来接收前端参数并进行封装
 */
public class InvokeReflectBean {

	public InvokeReflectBean(){
		
	}
	//public static Object full(String className,HttpServletRequest request){
	public static ActionForm InvokeBean(HttpServletRequest request){
		ActionForm actionForm = null;
		try{
			Class className = Class.forName(request.getParameter("FormBean"));
			actionForm = (ActionForm)className.newInstance();
			//获取所有的参数
			Field[] f_ar = className.getDeclaredFields();
			for(Field f:f_ar){
				
				f.setAccessible(true);
				//获取所有的属性值
				f.set(actionForm,request.getParameter(f.getName()));
				f.setAccessible(false);
			}
			
		}catch(Exception e){
			//记录异常信息
			//logger.error(e);
		}
		return actionForm;
	}
}
